<@ms.html5>
     <@ms.nav title="严选品类增加" back=true>
        <@ms.saveButton  onclick="save()"/>
    </@ms.nav>
    <@ms.panel>
        <@ms.form name="articleForm" isvalidation=true>
            <@ms.hidden name="gcId" value="${goodsChoose.gcId?default(0)}"/>
             <@ms.text name="chooseName" colSm="2" width="400" label="严选名称"    title="严选名称" size="5"  placeholder="严选名称"  value="${goodsChoose.chooseName?default('')}"  />
			
             <@ms.formRow colSm="2" label="保险栏目" width="400">
	            <@ms.treeInput treeId="inputTree" json="${columnList?default('')}" jsonId="categoryId" jsonPid="categoryCategoryId" jsonName="categoryTitle" inputName="categroyId"  inputValue="${categroyId?default(160)}" buttonText="选择栏目" clickZtreeId="clickZtreeId(event,treeId,treeNode);" expandAll="true"  showIcon="true"/>
			</@ms.formRow>
            
            <@ms.formRow colSm="2" label="严选背景图" width="400" >
					<@ms.uploadImg path="" uploadFloderPath="goodsChoose" inputName="image" size="1" msg="提示:严选产品背景图,支持jpg格式"  imgs="${goodsChoose.image?default('')}"    />
			</@ms.formRow>
			<@ms.text name="synopsis" colSm="2" width="400" label="简介"    title="简介" size="5"  placeholder="多行内容以|分割"  value="${goodsChoose.synopsis?default('')}"  />
			<@ms.text name="httpUrl" colSm="2" width="400" label="链接地址"    title="链接地址" size="5"  placeholder="请输入链接地址"  value="${goodsChoose.httpUrl?default('')}"  />
			<@ms.text name="detailText" colSm="2" width="400" label="明细标题头"    title="明细标题头" size="5"  placeholder="三个明细标题头,以|分割"  value="${goodsChoose.detailText?default('')}"  />
			<@ms.text name="insurance" colSm="2" width="400" label="商品信息"    title="商品信息" size="5"  placeholder="三个商品,以|分割"  value="${goodsChoose.insurance?default('')}"  />
			<@ms.text name="sort" colSm="2" width="400" label="排序"    title="排序" size="5"  placeholder="排序"  value="${goodsChoose.sort?default('')}"  />
        
        </@ms.form>
    </@ms.panel>
</@ms.html5>
<script>
    var url = "${managerPath}/goods/goodsChoose/save.do";
    if($("input[name = 'gcId']").val() > 0){
        url = "${managerPath}/goods/goodsChoose/update.do";
        $(".btn-success").text("更新");
    }
    //编辑按钮onclick
    function save() {
        $("#articleForm").data("bootstrapValidator").validate();
            var isValid = $("#articleForm").data("bootstrapValidator").isValid();
            if(!isValid) {
                <@ms.notify msg= "数据提交失败，请检查数据格式！" type= "warning" />
                return;
        }
        var btnWord =$(".btn-success").text();
        $(".btn-success").text(btnWord+"中...");
        $(".btn-success").prop("disabled",true);
        $.ajax({
            type:"post",
            dataType:"json",
            data:$("form[name = 'articleForm']").serialize(),
            url:url,
            success: function(status) {
                if(status.result == true) { 
                    <@ms.notify msg="保存或更新成功" type= "success" />
                    location.href = "${managerPath}/goods/goodsChoose/index.do";
                }
                else{
                    <@ms.notify msg= "保存或更新失败！值不合规则"  type= "fail" />
                    location.href= "${managerPath}/goods/goodsChoose/index.do";
                }
            }
        })
    }    
    
    //树形结点
	//选择栏目后查询自定义模型
function clickZtreeId(event,treeId,treeNode){
	if(treeNode.columnType == 2){
		<@ms.notify msg="不能选择单篇栏目" />
		return false;
	}
	if(treeNode.isParent==true){
		<@ms.notify msg="不能选择父级栏目" />
		return false;
	}
} 
</script>